package id.co.shuba.spamobile;

import id.co.shuba.spamobile.model.UserInfo;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Configs {	
	public static SharedPreferences getConfigs(Context ctx) {
		return ctx.getSharedPreferences("APP_CONFIG", Context.MODE_PRIVATE);
	}
	public static int getGuCloseDeal(Context ctx) {		
		return getConfigs(ctx).getInt("GU_CLOSE_DEAL", 14);		
	}	
	public static int getGuFup(Context ctx) {		
		return getConfigs(ctx).getInt("GU_FUP", 7);		
	}
	public static int getPurgingPeriod(Context ctx) {
		int val = getConfigs(ctx).getInt("PURGING_PERIOD", 3); 
		return (val < 0? val : val * -1) * 30;		
	}
	public static String getProcessDate(Context ctx) {
		return getConfigs(ctx).getString("PROCESS_DATE", App.dateTime.format(new java.util.Date()));
	}
	public static void setConfigs(Context ctx, int guCloseDeal, int guFup, int purgingPeriod, String processDate) {
		SharedPreferences settings = ctx.getSharedPreferences("APP_CONFIG", Context.MODE_PRIVATE);		
		Editor edit = settings.edit();
		edit.putInt("GU_CLOSE_DEAL", guCloseDeal);		
		edit.putInt("GU_FUP", guFup);
		edit.putInt("PURGING_PERIOD", purgingPeriod);
		edit.putString("PROCESS_DATE", processDate);
		edit.commit();		
	}
}
